package com.sfh.tourist;

import com.sfh.lib.IResultSuccess;
import com.sfh.lib.mvvm.BaseViewModel;

import java.io.File;

public class TouristModel extends BaseViewModel {

    public void pageLiat(int nopage){

    }


    public void onFile(String ...path){

        for (String file : path){
            this.execute( new ReqFile(new File(file)), new IResultSuccess<Result<String>>() {
                @Override
                public void onSuccess(Result<String> result) throws Exception {
                    if (result.successed){
                        setValue("onFileSuccess",true,file,result.data);
                    }else{
                        setValue("onFileSuccess",false, file);
                    }
                }
            });
        }

    }

    public void addInfo(ReqAddInfo info){
        this.execute(false,info, new IResultSuccess<Result>() {
            @Override
            public void onSuccess(Result result) throws Exception {
                if (result.successed){
                    setValue("onSuccess");
                }else{
                    showDialogToast(result.message);
                }
            }
        });
    }
}
